package com.atguigu.gulimall.order.vo;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Data
public class OrderConfirmVo {
    @Getter @Setter
    //收货地址,ums_member_receive_address 表
    List<MemberAddressVo> address;
    //所有选中的购物项
    @Getter @Setter
    List<OrderItemVo> items;
    //发票记录...
    //优惠卷信息...
    @Getter @Setter
    Integer integration;

    //防重令牌
    @Setter @Getter
    String orderToken;

    @Getter @Setter
    Map<Long,Boolean> stocks;

    BigDecimal total; //订单总额

    public BigDecimal getTotal() {
        BigDecimal sum =new BigDecimal("0");
        if(items != null){
            for (OrderItemVo item :items) {
              BigDecimal multipy = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
              sum = sum.add(multipy);
            }
        }

        return sum;
    }
    public Integer getCount(){
        Integer i = 0;
        if(items != null){
            for (OrderItemVo item : items){
                i+=item.getCount();
            }
        }
        return i;
    }


    public BigDecimal getPayPrice() {
        return getTotal();
    }

    public void setPayPrice(BigDecimal payPrice) {
        this.payPrice = payPrice;
    }

    BigDecimal payPrice; //应付价格
}
